package com.ccl.iot.ir;

import android.util.Log;

import com.hzy.tvmao.ir.Device;

/**
 * 创建者     王浩
 * 创建时间   2017/5/24 11:24
 * 描述	      ${TODO}
 */

public class BlirConst {


    //设备类型
    public static final String IR_SUBDEV_TYPE_TV = "TV";        //电视
    public static final String IR_SUBDEV_TYPE_PLAYER = "DVD";        //播放器
    public static final String IR_SUBDEV_TYPE_AMPLIFIER = "PA";      //功放
    public static final String IR_SUBDEV_TYPE_FAN = "FAN";      //风扇
    public static final String IR_SUBDEV_TYPE_AIRCONDITION = "AC";        //空调
    public static final String IR_SUBDEV_TYPE_STB = "STB";      //机顶盒
    public static final String IR_SUBDEV_TYPE_BOX = "BOX";      //盒子
    public static final String IR_SUBDEV_TYPE_LAMP = "Light";        //电灯
    public static final String IR_SUBDEV_TYPE_PROJECTOR = "PRO";      //投影仪
    public static final String IR_SUBDEV_TYPE_AIRPURIFIER = "AIR_CLEANER";      //空气净化器
    public static final String IR_SUBDEV_TYPE_SLR = "SLR";      //单反相机
    public static final String IR_SUBDEV_TYPE_WATER_HEATER = "WATER_HEATER";      //热水器
    public static final String IR_SUBDEV_TYPE_OTHER = "Other";      //其它类型
    public static final String IR_SUBDEV_TYPE_NON_STATE_AIRCONDITION = "NAC";      //无状态空调


//    sleep	睡眠
//    timing	定时

//            0	0
//            1	1
//            2	2
//            3	3
//            4	4
//            5	5
//            6	6
//            7	7
//            8	8
//            9	9
//    input	信号源
//    exit	退出
//    last	交替
//    display	屏显
//    homepage	主页
//    rewind	快退
//    play	播放
//    fast_forward	快进
//    record	录音
//    stop	停止
//    pause	暂停
//    previous	上一曲
//    info	信息
//    livetv	直播
//    red	红
//    green	绿
//    blue	蓝
//    yellow	黄
//    picture mode	图像模式
//    sound mode	声音模式
//    tv/radio	电视/广播
//3d	3D
//    pip	画中画
//    favorite	收藏
//    guide	指南
//    poweroff	Power Off
//    clear	清除
//    caption	字幕
//    tv	TV
//    energy save	节能
//    program list	节目列表
//    shortcut menu	快捷菜单
//    guides	导视
//    size	尺寸
//    av2	Av2
//    av1	Av1
//    inputtv	输入电视
//    teletext	图文
//    scale	比例
//    position	位置
//    network tv	网络电视
//    tool	工具
//    language selection	语言选择
//    list	列表
//    program guide	节目指南
//    hdmi1	HDMI1
//    hdmi2	HDMI2
//    hdmi3	HDMI3
//    brightness+	亮度+
//    brightness-	亮度-
//    tv/vid	TV/Vid
//    submenu	子菜单
//    dual-channel	双声道
//    aspect	比例调整
//    tv/rad	TV/Rad
//    netflix	Netflix
//10	10
//    power on	电源开
//    component1	分量1
//    component2	分量2
//    hdmi4	HDMI4
//    ad	AD
//    bs	BS
//    cs	CS
//12	12
//        11	11
//    fav	Fav
//    subtitle	Subtitle
//    favorites	Favorites
//    tvproglist	TvProgList
//    changesound	ChangeSound
//    av	AV
//    lld	LLD
//    dlinkeddata	dLinkedData
//-/--	-/--
//    settings	Settings
//    app	APP
//    flash back	Flashback
//    av 1	AV 1
//    av 2	AV 2
//    av 3	AV 3
//    simplink	SimpLink
//    avmode	AV Mode
//    inputrgb-pc	Rgb-Pc
//    qmenu	Q. Menu
//    ratio16x9	Ratio16x9
//    d/a	D/A
//    yahoo	Yahoo
//    API
//    screensize	ScreenSize
//    energysaving	EnergySaving
//    dash/list	Dash/List
//    fav/mark/char/num	Fav/Mark/Char/Num
//    premium	Premium




//    power	电源
//    ok	确认
//    menu	菜单
//    navigate_up	上
//    navigate_down	下
//    navigate_left	左
//    navigate_right	右
//    volume_up	音量+
//    volume_down	音量-
//            0	0
//            1	1
//            2	2
//            3	3
//            4	4
//            5	5
//            6	6
//            7	7
//            8	8
//            9	9
//    mute	静音
//    back	返回
//    exit	退出
//    rewind	快退
//    fast_forward	快进
//    eject	出仓
//    previous	上一曲
//    next	下一曲
//    caption	字幕
//    formats	制式

    //按键类型
    public static final String IR_KEYTYPE_POWER = "power";     //电源键
    public static final String IR_KEYTYPE_CH_ADD = "channel_up";      //频道加
    public static final String IR_KEYTYPE_CH_RDEDUCE = "channel_down";      //频道减
    public static final String IR_KEYTYPE_VOL_ADD = "volume_up";        //音量加
    public static final String IR_KEYTYPE_VOL_RDEDUCE = "volume_down";        //音量减
    public static final String IR_KEYTYPE_MUTE = "mute";       //静音键
    public static final String IR_KEYTYPE_MENU = "menu";       //菜单键
    public static final String IR_KEYTYPE_OK = "ok";       //确定键
    public static final String IR_KEYTYPE_RETURN = "back";       //返回键
    public static final String IR_KEYTYPE_UP = "navigate_up";       //方向键上
    public static final String IR_KEYTYPE_DOWN = "navigate_down";       //方向键下
    public static final String IR_KEYTYPE_LEFT = "navigate_left";       //方向键左
    public static final String IR_KEYTYPE_RIGHT = "navigate_right";     //方向键右
    public static final String IR_KEYTYPE_SOURCE = "input";       //音/视频源选择键
    public static final String IR_KEYTYPE_KEY0 = "0";       //按键0
    public static final String IR_KEYTYPE_KEY1 = "1";       //按键1
    public static final String IR_KEYTYPE_KEY2 = "2";       //按键2
    public static final String IR_KEYTYPE_KEY3 = "3";       //按键3
    public static final String IR_KEYTYPE_KEY4 = "4";       //按键4
    public static final String IR_KEYTYPE_KEY5 = "5";       //按键5
    public static final String IR_KEYTYPE_KEY6 = "6";       //按键6
    public static final String IR_KEYTYPE_KEY7 = "7";       //按键7
    public static final String IR_KEYTYPE_KEY8 = "8";       //按键8
    public static final String IR_KEYTYPE_KEY9 = "9";       //按键9
    public static final String IR_KEYTYPE_other = "-/--";       //按键-/--

    public static final String IR_KEYTYPE_PLAY = "play";             //播放键
    public static final String IR_KEYTYPE_PAUSE = "pause";           //暂停键
    public static final String IR_KEYTYPE_STOP = "stop";             //停止键
    public static final String IR_KEYTYPE_BACK = "previous";             //上一曲
    public static final String IR_KEYTYPE_NEXT = "next";             //下一曲
    public static final String IR_KEYTYPE_BACKWARD = "rewind";         //快退
    public static final String IR_KEYTYPE_FORWARD = "fast_forward";       //快进
    public static final String IR_KEYTYPE_OPEN = "eject";         //出仓

    public static final String IR_TIMING = "timing";         //定时
    public static final String IR_FAN_HEAD = "swing";         //摇头
    public static final String IR_FAN_SPEED = "fan_speed";         //风速
    public static final String IR_FAN_MODE = "swing_mode";         //风类

    public static final String IR_KEYTYPE_ZOOMOUT = "zoom_down";     //缩小
    public static final String IR_KEYTYPE_ZOOMIN = "zoom_up";       //放大
    public static final String IR_KEYTYPE_CUSTOM0 = "Custom0";     //第0号自定义按键
    public static final String IR_KEYTYPE_CUSTOM1 = "Custom1";     //第1号自定义按键
    public static final String IR_KEYTYPE_CUSTOM2 = "Custom2";     //第2号自定义按键
    public static final String IR_KEYTYPE_CUSTOM3 = "Custom3";     //第3号自定义按键
    public static final String IR_KEYTYPE_CUSTOM4 = "Custom4";     //第4号自定义按键
    public static final String IR_KEYTYPE_CUSTOM5 = "Custom5";     //第5号自定义按键
    public static final String IR_KEYTYPE_CUSTOM6 = "Custom6";     //第6号自定义按键
    public static final String IR_KEYTYPE_CUSTOM7 = "Custom7";     //第7号自定义按键
    public static final String IR_KEYTYPE_CUSTOM8 = "Custom8";     //第8号自定义按键
    public static final String IR_KEYTYPE_CUSTOM9 = "Custom9";     //第9号自定义按键


    public static final String ACT_GET = "get";

    public static final String ACT_SET = "set";

    /*
                 * public int STB = 1; //机顶盒
                 * public int TV  = 2; //电视
                 * public int BOX = 3; //网络盒子
                 * public int DVD = 4; //DVD
                 * public int AC  = 5; //空调
                 * public int PRO = 6; //投影仪
                 * public int PA  = 7; //功放
                 * public int FAN = 8; //风扇
                 * public int SLR = 9; //单反相机
                 * public int Light = 10; //开关灯泡
                 * public int AIR_CLEANER = 11;// 空气净化器
    		  	 * public int WATER_HEATER = 12;// 热水器
                 */
    public static String getDevType(int type){
        switch (type){
            case Device.STB:
                return IR_SUBDEV_TYPE_STB;
            case Device.TV:
                return IR_SUBDEV_TYPE_TV;
            case Device.BOX:
                return IR_SUBDEV_TYPE_BOX;
            case Device.DVD:
                return IR_SUBDEV_TYPE_PLAYER;
            case Device.AC:
                return IR_SUBDEV_TYPE_AIRCONDITION;
            case Device.PRO:
                return IR_SUBDEV_TYPE_PROJECTOR;
            case Device.PA:
                return IR_SUBDEV_TYPE_AMPLIFIER;
            case Device.FAN:
                return IR_SUBDEV_TYPE_FAN;
            case Device.SLR:
                return IR_SUBDEV_TYPE_SLR;
            case Device.LIGHT:
                return IR_SUBDEV_TYPE_LAMP;
            case Device.AIR_CLEANER:
                return IR_SUBDEV_TYPE_AIRPURIFIER;
            case Device.WATER_HEATER:
                return IR_SUBDEV_TYPE_WATER_HEATER;
        }

        return "";
    }


    public static String kk2bl(String code) {
        if(code == null){
            return null;
        }
        String[] arrCode = code.split(",");

        int length = arrCode.length;
        String finalCode = "";
        for (int i = 0; i < length; ++i) {
            int singleCode = 0;
            try {
                singleCode = Integer.parseInt(arrCode[i].trim()) / 30;
            } catch (Exception var3) {
                var3.printStackTrace();
            }
            String hexCode = Integer.toHexString(singleCode);
            if (singleCode > 0xFF) {
                if (hexCode.length() == 3) {
                    hexCode = "0" + hexCode;
                }
                finalCode += "00" + hexCode;
            } else {
                if (hexCode.length() == 1) {
                    hexCode = "0" + hexCode;
                }
                finalCode += hexCode;
            }
        }
        finalCode = "2600" + Integer.toHexString(length) + "00" + finalCode;
        Log.e("kk2bl", "finalCode: " + finalCode);
        return finalCode;
    }
}
